package org.onionframework.persistence.model;

import javax.persistence.MappedSuperclass;

import org.onionframework.persistence.extend.ExtendComponentUtils;
import org.onionframework.persistence.model.logic.Extendable;
import org.onionframework.persistence.model.support.ExtendComponent;

/**
 * 可扩展的实体类模型父类
 * 
 * @author allan
 *
 */
@MappedSuperclass
public abstract class ExtendableModel extends AbstractModel implements Extendable{

	private static final long serialVersionUID = -7467675188334002877L;

	protected ExtendComponent ex = ExtendComponentUtils.create(this.getClass());

	/**
	 * @param ex the ex to set
	 */
	public void setEx(ExtendComponent ex) {
		this.ex = ex;
	}

	@SuppressWarnings("unchecked")
	@Override
	public <T extends ExtendComponent> T getEx(Class<T> clazz) {
		return (T)this.ex;
	}
}
